//
//  ViewController.swift
//  ShakeViewKit
//
//  Created by JackMayxs on 07/12/2020.
//  Copyright (c) 2020 JackMayxs. All rights reserved.
//

import UIKit
import ShakeViewKit

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        let btn = UIButton(frame: CGRect(x: 100, y: 100, width: 80, height: 40))
        btn.addTarget(self, action: #selector(shakeViewMethods), for: UIControlEvents.touchDown)
        btn.backgroundColor = UIColor.red
        btn.setTitle("点我", for: UIControlState.normal)
        view.addSubview(btn)

        
        let arrays = [1,2,3,4,5]
        
        print(arrays[safe: 6])
        
        
        
    }
    
    @objc func shakeViewMethods() {
        let shakeView = UIView(frame: CGRect(x: 100, y: 200, width: 100, height: 50))
        shakeView.backgroundColor = UIColor.red
        view.addSubview(shakeView)
        shakeView.shake(direction: .horizontal, numberOfTimes: 10, totalDuration: 0.5) {
            /// complete do something
            print("view振动摇晃结束")
        }?.withHapticVibration(.heavy)
        
    }

}

